<%--
  Created by IntelliJ IDEA.
  User: sc
  Date: 2020/7/30
  Time: 16:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>首页</title>

    <style type="text/css">
        #first {
            margin: 0 auto;
            width: 460px;
        }

        a {
            text-decoration: none;
            color: blue;
        }
    </style>

    <script src="<%=request.getContextPath()%>/js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        $(function() {
            var book = $(".condition").val();
            alert(book);
            if (book == "书名") {
                $(".b").attr("name","bookName");
            }else if(book=="作者"){
                $(".b").attr("name","bookAuthor");
            }else{
                $(".b").attr("name","bookPublish");
            }
            alert($(".b").attr("name"));
        })
    </script>

</head>
<body>
<div id="first">
    <table border="1" cellspacing="1" cellpadding="5">
        <tr>
            <td colspan="5" align="center">
                <form action="criteriaQuery" method="post">
                    <select name="book" class="condition">
                        <option selected="selected">书名</option>
                        <option>作者</option>
                        <option>出版社</option>
                    </select>
                    &nbsp;&nbsp;
                    <%--<c:if test="${not empty bookName1}"></c:if>--%>

                    <input type="text" class="b" name="bookName"/>

                    <%--<input type="text" name="bookAuthor"/>作者--%>

                    <%--<input type="text" name="bookPublish"/>出版社--%>

                    &nbsp;&nbsp;
                    <input type="submit" value="提交"/>
                </form>
            </td>
        </tr>
        <tr>
            <td align="center">书名</td>
            <td align="center">作者</td>
            <td align="center">出版社</td>
            <td align="center">页数</td>
            <td align="center">价格</td>
        </tr>
        <tr>
            <td colspan="5" align="right"><a href="<%=request.getContextPath()%>/add.jsp">增加新书</a></td>
        </tr>
        <c:forEach items="${list}" var="b">
            <tr>
                <td align="left">${b.bookName}</td>
                <td align="left">${b.bookAuthor}</td>
                <td align="left">${b.bookPublish}</td>
                <td align="left">${b.bookPage}</td>
                <td align="left">${b.bookPrice}</td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
